.html_title= @html_title
/! 搜索表单
.search_form
  - @search||= User.ransack {}
  = search_form_for(@search, url: user_trainee_title_index_users_path, builder: SimpleForm::FormBuilder, class: "index_search_form") do |f|
    .pull-left.push-10-l= per_page_select
    = f.input_field :login_cont, placeholder: (User.t :login), class: "form-control"
    = f.input_field :name_cont, placeholder: (User.t :name), class: "form-control"
    = f.input_field :school_id_eq, collection: School.options_for_select, include_blank: (User.t :school_id), class: "form-control"
    = f.input_field :trainee_title_id_eq, collection: Trainee::Title.options_for_select, include_blank: (User.t :trainee_title_id), class: "form-control"
    = search_button f
.radius-block
  /! 数据列表
  table.index-data-table
    thead
      tr
        th style='width: 200px' = User.t :name
        th= User.t :school_id
        th= User.t :trainee_title_id
    tbody
      - @users.each do |user|
        tr
          td = user.info
          td = user.school
          td = select_tag "user_train_title_#{user.id}", options_for_select(@trainee_title_options, user.trainee_title_id), prompt: "", class: "form-control user-train-title-selector", data: {user_id: user.id}
  = paginate @users

coffee:
  $('.user-train-title-selector').change ->
    user_id = $(this).data('user-id')
    trainee_title_id = $(this).val()
    if trainee_title_id != ""
      $.ajax(
        url: '/users/' + user_id + '/update_user_trainee_title',
        type: 'put',
        data: {trainee_title_id: trainee_title_id},
        dataType: 'script'
      )